// Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RERUN_TOOLS_CPP_PCL_UTILS_H
#define RERUN_TOOLS_CPP_PCL_UTILS_H

#include <cstddef>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <rerun/datatypes/vec3d.hpp>

extern "C" {
pcl::PointCloud<pcl::PointXYZ>* new_xyz_point_cloud();
pcl::PointCloud<pcl::PointXYZI>* new_xyzi_point_cloud();
void delete_xyz_point_cloud(pcl::PointCloud<pcl::PointXYZ> *cloud);
void delete_xyzi_point_cloud(pcl::PointCloud<pcl::PointXYZI> *cloud);
int load_xyz_pcd_file(char *file_name, size_t name_len, pcl::PointCloud<pcl::PointXYZ> *cloud, size_t *size);
int load_xyzi_pcd_file(char *file_name, size_t name_len, pcl::PointCloud<pcl::PointXYZI> *cloud, size_t *size);
void cloud_xyz_to_vecs3d(pcl::PointCloud<pcl::PointXYZ> *cloud, rerun::datatypes::Vec3D *vecs);
void cloud_xyzi_to_vecs3d(pcl::PointCloud<pcl::PointXYZI> *cloud, float *vec_with_i);
void cloud_xyzi_to_position3d(pcl::PointCloud<pcl::PointXYZI> *cloud, rerun::datatypes::Vec3D *position3d);
void cloud_xyzi_to_intensity(pcl::PointCloud<pcl::PointXYZI> *cloud, float *intensity);
}

#endif